博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Open edX课程数据的存储方式
阅读量:5900 次
发布时间:2019-06-19

本文共 5605 字,大约阅读时间需要 18 分钟。

  hot3.png

openEDX课程数据的存储方式在官方文档中一节说明了其设计的核心思想,本文简单解释一下它的存储方式并通过查看数据库存储的内容来进一步了解它。

每个课程的数据都分三部分:

  • Course Index 课程最基本的数据,比如课程代码、单位等,其中最重要的是两个ObjectID,一个是已发布的课程Course Structures,另一个编辑中的课程Course Structures
  • Course Structures,记录着课程的主要内容和结构,包含多个block,其中默认包含course和overview两个block,所有的block都有自己的ObjectID,它指向XBlock Definitions
  • XBlock Definitions 记录block的具体数据。

下面是mongodb中的collections

root@i-7kvy76cm:/edx# mongoMongoDB shell version: 2.6.11connecting to: test> use edxappswitched to db edxapp> show collectionsfs.chunksfs.filesmodulestore.active_versions # 即是Course Indexmodulestore.definitions # 即是XBlock Definitionsmodulestore.structures # 即是Course Structuressystem.indexes

modulestore.active_versions中的数据大致是这样

{ "_id": ObjectId("5632e46950e3432ed9f51b08"), "course": "test10code", # 课程代码 "edited_on": ISODate("2015-10-30T03:30:49.380Z"), "run": "2015", "versions": { "draft-branch": ObjectId("5632e46950e3432ed9f51b07"),# 编辑版Course Structures "published-branch": ObjectId("5632e46950e3432ed9f51b09") }, # 发布版Course Structures "search_targets": { "wiki_slug": "test10org.test10code.2015" }, "org": "test10org", # 单位代码 "edited_by": NumberLong(9), "schema_version": 1, "last_update": ISODate("2015-10-30T03:30:49.564Z")}

Course Structures的json数据大致是这样:

{ "_id": ObjectId("5632e84650e3432ed9f51b0b"), "edited_by": NumberLong(9), "previous_version": ObjectId("5632e83550e3432edcf51b07"), "original_version": ObjectId("5632e46950e3432ed9f51b07"), "schema_version": 1, "edited_on": ISODate("2015-10-30T03:47:18.352Z"), "blocks": [ # blocks列表,第一个是新添加一个章节数据test-chapter1 { "definition": ObjectId("5632e83550e3432edcf51b06"), "block_type": "chapter", "block_id": "7270a053884041a2b2cc0e64065970f2", "fields": { "display_name": "test-chapter1" }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": ObjectId("5632e83550e3432edcf51b07"), "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:47:18.352Z"), "source_version": null, "update_version": ObjectId("5632e84650e3432ed9f51b0b") } }, { # 第二是默认存在的基本course的block,它设定了课程包含哪几大块内容,比如课件、更新通知、教材、论坛、wiki等 "definition": ObjectId("5632e46950e3432ed9f51b06"), "block_type": "course", "block_id": "course", "fields": { "display_name": "test10name", "language": "en", "tabs": [ { "type": "courseware", "name": "Courseware" }, { "type": "course_info", "name": "Course Info" }, { "type": "textbooks", "name": "Textbooks" }, { "type": "discussion", "name": "Discussion" }, { "type": "wiki", "name": "Wiki" }, { "type": "progress", "name": "Progress" } ], "discussion_topics": { "一般": { "id": "course" } }, "start": ISODate("2030-01-01T00:00:00Z"), "children": [ [ "chapter", "7270a053884041a2b2cc0e64065970f2" ] ] }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": ObjectId("5632e46950e3432ed9f51b07"), "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:47:01.568Z"), "source_version": null, "update_version": ObjectId("5632e83550e3432edcf51b07") } }, { # 默认存在overview block,它是课程介绍页面的内容 "definition": ObjectId("5632e46950e3432ed9f51b0a"), "block_type": "about", "block_id": "overview", "fields": { "display_name": "overview" }, "defaults": { }, "edit_info": { "edited_by": NumberLong(9), "previous_version": null, "original_usage_version": null, "original_usage": null, "edited_on": ISODate("2015-10-30T03:30:49.558Z"), "source_version": null, "update_version": ObjectId("5632e46950e3432ed9f51b07") } } ], "root": [ "course", "course" ]}

XBlock Definitions存储具体的block,比如:

{ "_id": ObjectId("5632e46950e3432ed9f51b06"), "fields": { "wiki_slug": "test10org.test10code.2015" }, "edit_info": { "edited_on": ISODate("2015-10-30T03:30:49.380Z"), "edited_by": NumberLong(9), "original_version": ObjectId("5632e46950e3432ed9f51b06"), "previous_version": null }, "block_type": "course", "schema_version": 1}{ "_id": ObjectId("5632e46950e3432ed9f51b0a"), "fields": { "data": "
\n

About This Course

\n

Include your long course description here. The long course description should contain 150-400 words.

\n\n

This is paragraph 2 of the long course description. Add more paragraphs as needed. Make sure to enclose them in paragraph tags.

\n
\n\n
\n

Requirements

\n

Add information about the skills and knowledge students need to take this course.

\n
\n\n
\n

Course Staff

\n
\n
\n
\"Course\n
\n\n

Staff Member #1

\n

Biography of instructor/staff member #1

\n
\n\n
\n
\n
\"Course\n
\n\n

Staff Member #2

\n

Biography of instructor/staff member #2

\n
\n
\n\n
\n
\n

Frequently Asked Questions

\n
\n

Do I need to buy a textbook?

\n

No, a free online version of Chemistry: Principles, Patterns, and Applications, First Edition by Bruce Averill and Patricia Eldredge will be available, though you can purchase a printed version (published by FlatWorld Knowledge) if you’d like.

\n
\n\n
\n

Question #2

\n

Your answer would be displayed here.

\n
\n
\n
\n" }, "edit_info": { "edited_on": ISODate("2015-10-30T03:30:49.557Z"), "edited_by": NumberLong(9), "original_version": ObjectId("5632e46950e3432ed9f51b0a"), "previous_version": null }, "block_type": "about", "schema_version": 1}

 

Mongodb操作记录:

1. 更新指定条件其中多少条记录:

db.modulestore.active_versions.find({org:"LzSH"}).limit(50).forEach(function(doc){ db.modulestore.active_versions.update({_id:doc._id},{$set:{org:"LzSouth"}})})

 

转载于:https://my.oschina.net/moks/blog/1602264

你可能感兴趣的文章
浏览器兼容性工具 Spoon Browser Sandbox
查看>>
[转]用Ant实现Java项目的自动构建和部署
查看>>
5.4.4 表
查看>>
Codeforces 817F - MEX Queries
查看>>
软件需求规格说明书
查看>>
纯CSS实现展开列表
查看>>
算法基础-打开算法之门 (Thomas H.Corme 著)
查看>>
jQuery+bootstrap实现美化警告/确认/提示对话框插件
查看>>
js实现table内 某列的内容进行即时筛选
查看>>
JAVA特性-跨平台/面向对象
查看>>
利用Win10计划任务 + 弹窗,提醒你自己
查看>>
《php和mysql web开发》读书笔记
查看>>
第二章 生成、打包、部署和管理应用程序及类型
查看>>
Generate Parentheses
查看>>
括号配对问题2
查看>>
C#性能优化实践
查看>>
[HTML/CSS]display:none和visibility:hidden的区别
查看>>
Xcode导入第三方库
查看>>
css required,focus,valid和invalid介绍
查看>>
C# arcengine 由FeatureClass生成TIN
查看>>